<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/4/9 0009
 * Time: 11:00
 */

namespace app\wap\controller;
use think\Db;

class Venues  extends Base
{
        public function index(){
            $Scenery = intval(input('param.Scenery'));
            $where ='is_show=1 and sign="mobile" and is_del = 0';
            if($Scenery){
                $where .=' and Scenery = '.$Scenery;
                $this->assign('Scenery',$Scenery);
            }else{
                $where .=' and Scenery = 1';
                $this->assign('Scenery',1);
            }
            //基地
            $data_jd = Db::name('psjd')->where($where)->order('sort desc,id desc')->limit(10)->select();
            $this->assign('data_jd',$data_jd);
            //判断否有第二页的数据)
            $type =1;
            $next_data= Db::name('psjd')->where($where)->page(2,10)->select();
            if(!$next_data){
                $type =2;
            }
            $this->assign('type',$type);
            $this->assign('data_seo',getColumnseo(4));
            return $this->fetch();

        }


        public function nr(){

            $id = intval(input('param.id'));
            if($id){
                $data = Db::name('psjd')->where('id',$id)->find();
                $this->assign('data',$data);
            }

            return $this->fetch();
        }


    public function getMore(){
        $page = intval(input('post.page'));
        $Scenery = intval(input('post.Scenery'));
        $where ='is_show=1 and sign="mobile" and is_del = 0';
        if($Scenery){
            $where .=' and Scenery = '.$Scenery;

        }
        $type =1;
        $res= Db::name('psjd')->where($where)->page($page,10)->select();
        $next_data= Db::name('psjd')->where($where)->page($page+1,10)->select();
        if(!$next_data){
            $type =2;
        }
        if($res){
            return json(['code'=>1,'data'=>$res,'type'=>$type]);
        }else{
            return json(['code'=>0,'msg'=>'没有更多了']);
        }

    }
}